<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/1/12
  Time: 22:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link href="${pageContext.request.contextPath}/statics/Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/typeahead-bs2.min.js"></script>
    <!-- page specific plugin scripts -->
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script type="${pageContext.request.contextPath}/statics/text/javascript" src="js/H-ui.js"></script>
    <script type="${pageContext.request.contextPath}/statics/text/javascript" src="js/H-ui.admin.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/layer/layer.js" type="text/javascript" ></script>
    <script src="${pageContext.request.contextPath}/statics/assets/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/zTree/js/jquery.ztree.all-3.5.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/js/lrtk.js" type="text/javascript" ></script>
    <title>已审核商品列表</title>
</head>
<body>
<div class=" page-content clearfix">
    <div id="products_style">
        <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:activebysel(1)" title="批量通过" class="btn btn-warning Order_form"><i class="icon-plus"></i>批量通过</a>
        <a href="javascript:ovid()" class="btn btn-danger"><i class="icon-trash"></i>批量拒绝</a>
       </span>
        </div>
        <div class="row" style="margin: 20px 0px">
            <div class="col-md-12">
                <form action="${pageContext.request.contextPath}/manager/menuitem/putture" method="get" class="form-inline">
                    <input type="hidden" name="pageindex" value="1"/>
                    <div class="form-group">
                        <label>商家名称:</label>
                        <input type="text" name="bname" value="${bname}">
                    </div>
                    <div class="form-group">
                        <label>商品名称:</label>
                        <input type="text" name="mname" value="${mname}">
                    </div>
                    <div class="form-group">
                        <label>商品类型:</label>
                        <input type="text" name="ccName" value="${ccName}">
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-info">搜索</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="table_menu_list clearfix" id="testIframe" style="width:100%">
            <table class="table table-striped table-bordered table-hover" id="sample-table" >
                <thead>
                <tr>
                    <th width="25px"><label><input type="checkbox" class="ace" id="selectAll"><span class="lbl"></span></label></th>
                    <th width="80px">商品编号</th>
                    <th width="250px">商家名称</th>
                    <th width="100px">商品类别</th>
                    <th width="100px">商品名称</th>
                    <th width="100px">商品价格</th>
                    <th width="100px">配送金额</th>
                    <th width="100px">商品图片</th>
                    <th width="100px">商品简介</th>
                    <th width="100px">是否特价</th>
                    <th width="100px">商品特价</th>
                    <th width="100px">商家状态</th>
                    <th width="200px">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="mc" items="${pageInfo.list}">
                    <tr>
                        <td width="25px"><label><input type="checkbox" class="ace" name="inputdel" value="${mc.mid}" ><span class="lbl"></span></label></td>
                        <td width="80px">${mc.mid}</td>
                        <td width="250px"><u style="cursor:pointer" class="text-primary" onclick="">${mc.business.bname}</u></td>
                        <td width="100px">${mc.classification.ccName}</td>
                            <%--                        <td width="100px"><img src="${pageContext.request.contextPath}/statics/upload/category/${mc.mcIcon}" height="50"/></td>--%>
                        <td width="100px">${mc.mname}</td>
                        <td width="100px">${mc.mprice}</td>
                        <td width="100px">${mc.deliveryAmount}</td>
                        <td width="100px"><img src="${pageContext.request.contextPath}/statics/upload/menuitem/${mc.mimg}" width="100px" height="100px"/></td>
                        <td width="100px">${mc.mdesc}</td>
                        <c:choose>
                            <c:when test="${mc.mspecialOffer}">
                                <td width="100px"><span class="text-success">是</span></td>
                            </c:when>
                            <c:otherwise>
                                <td width="100px"><span class="text-warning">否</span></td>
                            </c:otherwise>
                        </c:choose>
                        <td width="100px">${mc.specialOffer}</td>
                        <c:choose>
                            <c:when test="${mc.putShelves}">
                                <td width="100px"><span class="label label-success radius">已启用</span></td>
                            </c:when>
                            <c:otherwise>
                                <td width="100px"><span class="label label-default radius">未启用</span></td>
                            </c:otherwise>
                        </c:choose>
                        <td class="td-manage">
                                <%--                            <a onClick="member_stop(this,'10001')"  href="javascript:;" title="停用"  class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>--%>
                                <%--                            <a title="编辑" href="${pageContext.request.contextPath}/manager/category/update?id=${mc.mcId}"  class="btn btn-xs btn-info" ><i class="icon-edit bigger-120"></i></a>--%>
                                <%--                            <a title="删除" href="javascript:;"  onclick="member_del(this,${mc.mcId})" class="btn btn-xs btn-warning" ><i class="icon-trash  bigger-120"></i></a>--%>
                            <c:choose>
                                <c:when test="${mc.putShelves}">
                                    <button type="button" class="btn btn-warning" onclick="stopBtn(${mc.mid})"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-x-fill" viewBox="0 0 16 16">
                                        <path d="M6.5 0A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3Zm3 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3Z"/>
                                        <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1A2.5 2.5 0 0 1 9.5 5h-3A2.5 2.5 0 0 1 4 2.5v-1Zm4 7.793 1.146-1.147a.5.5 0 1 1 .708.708L8.707 10l1.147 1.146a.5.5 0 0 1-.708.708L8 10.707l-1.146 1.147a.5.5 0 0 1-.708-.708L7.293 10 6.146 8.854a.5.5 0 1 1 .708-.708L8 9.293Z"/>
                                    </svg>停用</button>
                                </c:when>
                                <c:otherwise>
                                    <button type="button" class="btn btn-success" onclick="actBtn(${mc.mid})"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-check-fill" viewBox="0 0 16 16">
                                        <path d="M6.5 0A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3Zm3 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3Z"/>
                                        <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1A2.5 2.5 0 0 1 9.5 5h-3A2.5 2.5 0 0 1 4 2.5v-1Zm6.854 7.354-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 0 1 .708-.708L7.5 10.793l2.646-2.647a.5.5 0 0 1 .708.708Z"/>
                                    </svg>通过</button>
                                </c:otherwise>
                            </c:choose>
                                <%--                            <a href="${pageContext.request.contextPath}/manager/business/detail?bid=${mc.mid}" class="btn btn-danger"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-archive" viewBox="0 0 16 16">--%>
                                <%--                                <path d="M0 2a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1v7.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V5a1 1 0 0 1-1-1V2zm2 3v7.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V5H2zm13-3H1v2h14V2zM5 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/>--%>
                                <%--                            </svg>拒绝</a>--%>
                            <button type="button" class="btn btn-danger" onclick="member_del(this,${mc.mid})"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-check-fill" viewBox="0 0 16 16">
                                <path d="M0 2a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1v7.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 12.5V5a1 1 0 0 1-1-1V2zm2 3v7.5A1.5 1.5 0 0 0 3.5 14h9a1.5 1.5 0 0 0 1.5-1.5V5H2zm13-3H1v2h14V2zM5 7.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/>
                            </svg>拒绝</button>
                        </td>
                    </tr>
                </c:forEach>

                </tbody>
                <%--                <c:choose>--%>
                <%--                    <c:when test="${pageInfo.hasPreviousPage}">--%>
                <%--                        <a href="${pageContext.request.contextPath}/manager/category/list?pageIndex=${pageInfo.prePage}">上一页</a>--%>
                <%--                    </c:when>--%>
                <%--                    <c:otherwise>--%>
                <%--                        <a href="${pageContext.request.contextPath}/manager/category/list?pageIndex=1">上一页</a>--%>
                <%--                    </c:otherwise>--%>
                <%--                </c:choose>--%>
                <%--                ${pageInfo.pageNum}/${pageInfo.pages}--%>
                <%--                <c:choose>--%>
                <%--                    <c:when test="${pageInfo.hasNextPage}">--%>
                <%--                        <a href="${pageContext.request.contextPath}/manager/category/list?pageIndex=${pageInfo.nextPage}">下一页</a>--%>
                <%--                    </c:when>--%>
                <%--                    <c:otherwise>--%>
                <%--                        <a href="${pageContext.request.contextPath}/manager/category/list?pageIndex=${pageInfo.pages}">下一页</a>--%>
                <%--                    </c:otherwise>--%>
                <%--                </c:choose>--%>

            </table>
            <c:if test="${empty pageInfo.list}">
                <h4 style="text-align: center">暂无数据</h4>
            </c:if>
        </div>
        <div class="container text-center">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isFirstPage}">
                                <a href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=1" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.prePage}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                    <%--el标签的其中一个for循环--%>
                    <c:choose>
                        <c:when test="${pageInfo.pages<=10}">
                            <c:set var="startpage" value="1"></c:set>
                            <c:set var="endpage" value="${pageInfo.pages}"></c:set>
                        </c:when>
                        <c:otherwise>
                            <c:choose>
                                <c:when test="${pageInfo.pageNum<10}">
                                    <c:set var="startpage" value="1"></c:set>
                                    <c:set var="endpage" value="10"></c:set>
                                </c:when>
                                <c:when test="${pageInfo.pages-pageInfo.pageNum<=5}">
                                    <c:set var="startpage" value="${pageInfo.pageSum-10}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageSum}"></c:set>
                                </c:when>
                                <c:otherwise>
                                    <c:set var="startpage" value="${pageInfo.pageNum-4}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageNum+5}"></c:set>
                                </c:otherwise>
                            </c:choose>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach begin="${startpage}" end="${endpage}" step="1" varStatus="status">
                        <c:choose>
                            <c:when test="${status.index==pageInfo.pageNum}">
                                <li class="active">
                            </c:when>
                            <c:otherwise>
                                <li>
                            </c:otherwise>
                        </c:choose>
                        <a href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${status.index}">${status.index}</a></li>
                    </c:forEach>
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isLastPage}">
                                <a href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.pages}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.nextPage}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</div>
<script>

    $(function () {
        //全选
        $("#selectAll").on("change",function () {
            // $("input[name='inputdel']").each(function () {
            //     $(this).prop("checked",$("#selectAll").prop("checked"))
            // })
            $("input[name='inputdel']").prop("checked",$(this).prop("checked"))
        })
    })

    /*批量启用或停用商品*/
    function activebysel(putShelves) {
        var input = $("input[name='inputdel']:checked");
        var params = input.toArray();
        for(var i=0;i<input.length;i++){
            params[i]=input[i].value;
        }

        $.ajax({
            type:"post",
            url:"${pageContext.request.contextPath}/manager/menuitem/updateMenu",
            contentType:"application/x-www-form-urlencoded",
            data:{
                "ids":params,
                "putShelves":putShelves
            },
            dataType:"json",
            success:res=>{
                if (res.code==200){
                    alert(res.message);
                    window.location.href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.pageNum}"
                }else {
                    alert(res.message)
                }
            }
        })
    }

    //停用一个商品
    function stopBtn(mid) {
        var b = confirm("确认要停用该商品吗?");
        if (b){
            $.getJSON("${pageContext.request.contextPath}/manager/menuitem/updateMenu",{"mid":mid,"putShelves":false},function (e) {
                if (e.code==200){
                    alert(e.message)
                    window.location.href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.pageNum}";
                }else {
                    alert(e.message)
                }
            })
        }
    }

    //通过一个商品
    function actBtn(mid) {
        $.getJSON("${pageContext.request.contextPath}/manager/menuitem/updateMenu",{"mid":mid,"putShelves":true},function (e) {
            if (e.code==200){
                alert(e.message)
                window.location.href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=${pageInfo.pageNum}";
            }else {
                alert(e.message)
            }
        })
    }

    function member_del(target,id) {
        var isok = confirm("确认要拒绝吗？");
        if (isok){
            $.getJSON("${pageContext.request.contextPath}/manager/menuitem/delMenu",{"mid":id},function (e) {
                if (e.code==200){
                    alert(e.message);
                    /*删除dom元素*/
                    $(target).parent().parent().remove();
                }else {
                    alert(e.message)
                    // console.log(e)
                }
            })
        }
    }

    function ovid() {
        var b = confirm("确认要批量拒绝吗?");
        if (b){
            var list = $(".ace[name='inputdel']:checked");
            var params = list.toArray();
            for (var i=0;i<list.length;i++){
                params[i]=list[i].value;
            }

            $.getJSON("${pageContext.request.contextPath}/manager/menuitem/delbyids",{"ids":params},function (e) {
                if (e.code==200){
                    alert(e.message);
                    /*删除dom元素*/
                    window.location.href="${pageContext.request.contextPath}/manager/menuitem/puttrue?pageindex=1"
                }else {
                    alert(e.message)
                    // console.log(e)
                }
            })
        }

    }
</script>
</body>
</html>
<%--<script>--%>
<%--    jQuery(function($) {--%>
<%--        var oTable1 = $('#sample-table').dataTable( {--%>
<%--            "aaSorting": [[ 1, "desc" ]],//默认第几个排序--%>
<%--            "bStateSave": true,//状态保存--%>
<%--            "aoColumnDefs": [--%>
<%--                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示--%>
<%--                {"orderable":false,"aTargets":[0,2,3,4,5,8,9]}// 制定列不参与排序--%>
<%--            ] } );--%>


<%--        $('table th input:checkbox').on('click' , function(){--%>
<%--            var that = this;--%>
<%--            $(this).closest('table').find('tr > td:first-child input:checkbox')--%>
<%--                .each(function(){--%>
<%--                    this.checked = that.checked;--%>
<%--                    $(this).closest('tr').toggleClass('selected');--%>
<%--                });--%>

<%--        });--%>


<%--        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});--%>
<%--        function tooltip_placement(context, source) {--%>
<%--            var $source = $(source);--%>
<%--            var $parent = $source.closest('table')--%>
<%--            var off1 = $parent.offset();--%>
<%--            var w1 = $parent.width();--%>

<%--            var off2 = $source.offset();--%>
<%--            var w2 = $source.width();--%>

<%--            if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';--%>
<%--            return 'left';--%>
<%--        }--%>
<%--    });--%>
<%--    laydate({--%>
<%--        elem: '#start',--%>
<%--        event: 'focus'--%>
<%--    });--%>
<%--    $(function() {--%>
<%--        $("#products_style").fix({--%>
<%--            float : 'left',--%>
<%--            //minStatue : true,--%>
<%--            skin : 'green',--%>
<%--            durationTime :false,--%>
<%--            spacingw:30,//设置隐藏时的距离--%>
<%--            spacingh:260,//设置显示时间距--%>
<%--        });--%>
<%--    });--%>
<%--</script>--%>


